| API Documentation |  |

- MAIN PAGE
- NAMESPACES
- CLASSES

Public Types | Public Member Functions | List of all members
nkGraphics::ShaderInstanceMemorySlot Class Reference

A memory slot for per instance data in a Shader. More...

Inheritance diagram for nkGraphics::ShaderInstanceMemorySlot:

## Public Types
enum | DATA_TYPE { DATA_TYPE::UNKNOWN = 0, DATA_TYPE::WORLD_MATRIX, DATA_TYPE::WORLD_MATRIX_INV_TRANSPOSE, DATA_TYPE::CUSTOM }

## Public Member Functions
| ShaderInstanceMemorySlot (System *system) noexcept
virtual | ~ShaderInstanceMemorySlot ()
DATA_TYPE | getType () const
nkMemory::StringView | getSemanticName () const
virtual unsigned int | getDataSize () const
virtual nkMemory::StringView | getDataTypeAsString () const override
void | setAsWorldMatrix ()
void | setAsWorldMatrixInvTranspose ()
void | setAsCustom (ShaderInstanceCustomSlot *slot)
virtual void | exportClassToTree (nkExport::Node *rootNode) override
virtual void | importClassFromTree (nkExport::Node *rootNode) override
Public Member Functions inherited from nkGraphics::ShaderMemorySlot
| ShaderMemorySlot () noexcept
virtual | ~ShaderMemorySlot ()
nkMemory::StringView | getSlotType () const
Public Member Functions inherited from nkExport::Exportable
| Exportable () noexcept
virtual | ~Exportable ()

## Detailed Description

A memory slot for per instance data in a Shader.

These slots are fed within a Shader, and offer the capabilities of feeding per instance data to a Program.

## Member Enumeration Documentation

## ◆ DATA_TYPE

enum nkGraphics::ShaderInstanceMemorySlot::DATA_TYPE
| strong

Describes the type of data an instance slot can be.

Enumerator
UNKNOWN | Unknown place holder.
WORLD_MATRIX | Instance's world matrix.
WORLD_MATRIX_INV_TRANSPOSE | Instance's world matrix, inversed and transposed.
CUSTOM | Custom instance slot, coming from external code.

## Constructor & Destructor Documentation

## ◆ ShaderInstanceMemorySlot()

nkGraphics::ShaderInstanceMemorySlot::ShaderInstanceMemorySlot | ( | System * | system | ) |
| noexcept

Constructor. See Shader::addInstanceMemorySlot().

Parameters

  system | The system the resource should live in.

## ◆ ~ShaderInstanceMemorySlot()

virtual nkGraphics::ShaderInstanceMemorySlot::~ShaderInstanceMemorySlot | ( |  | ) |
| virtual

Destructor.

## Member Function Documentation

## ◆ getType()

DATA_TYPE nkGraphics::ShaderInstanceMemorySlot::getType | ( |  | ) | const

Returns
  The slot type.

## ◆ getSemanticName()

nkMemory::StringView nkGraphics::ShaderInstanceMemorySlot::getSemanticName | ( |  | ) | const

Returns
  The semantic name provided by the slot.

## ◆ getDataSize()

virtual unsigned int nkGraphics::ShaderInstanceMemorySlot::getDataSize | ( |  | ) | const
| virtual

Returns
  The size, in byte, the slot needs to write for an instance.

## ◆ getDataTypeAsString()

virtual nkMemory::StringView nkGraphics::ShaderInstanceMemorySlot::getDataTypeAsString | ( |  | ) | const
| override virtual

Returns
  The data type, already translated as a string.

Implements nkGraphics::ShaderMemorySlot.

## ◆ setAsWorldMatrix()

void nkGraphics::ShaderInstanceMemorySlot::setAsWorldMatrix | ( |  | ) |

Prepare the slot to feed world matrices.

This adds a WORLD_MATRIX attribute within the declaration of mesh data. In HLSL, for instance, data can then be accessed like such :

struct VertexInput
{
float4 position : POSITION ;
float4x4 world : WORLD_MATRIX ;
} ;

The matrix is provided as row-major, meaning they can be used like :

float4x4 mvp = mul(projection, mul(view, world)) ;

## ◆ setAsWorldMatrixInvTranspose()

void nkGraphics::ShaderInstanceMemorySlot::setAsWorldMatrixInvTranspose | ( |  | ) |

Prepare the slot to feed world matrices, inversed and transposed.

This adds a WORLD_MATRIX_INVERSE_TRANSPOSE attribute within the declaration of mesh data. In HLSL, for instance, data can then be access like such :

struct VertexInput
{
float4 position : POSITION ;
float4x4 worldInvTranspose : WORLD_MATRIX_INVERSE_TRANSPOSE ;
} ;

The matrix is provided as row-major, meaning they can be used like :

float4 inv = mul(worldInvTranspose, vec) ;

This matrix can be useful to work with normals.

## ◆ setAsCustom()

void nkGraphics::ShaderInstanceMemorySlot::setAsCustom | ( | ShaderInstanceCustomSlot * | slot | ) |

Prepares the slot to use a custom slot to feed the data.

Parameters

  slot | The custom slot that should feed the data.

## ◆ exportClassToTree()

virtual void nkGraphics::ShaderInstanceMemorySlot::exportClassToTree | ( | nkExport::Node * | rootNode | ) |
| override virtual

Basic exporting capabilities.

Parameters

  rootNode | The tree to export to.

Reimplemented from nkGraphics::ShaderMemorySlot.

## ◆ importClassFromTree()

virtual void nkGraphics::ShaderInstanceMemorySlot::importClassFromTree | ( | nkExport::Node * | rootNode | ) |
| override virtual

Basic importing capabilities.

Parameters

  rootNode | The tree to import from.

Implements nkExport::Exportable.

The documentation for this class was generated from the following file:

- Documentation/Headers/NilkinsGraphics/Shaders/Memory/ShaderInstanceMemorySlot.h